home *** CD-ROM | disk | FTP | other *** search
- /* Advanced Laser Chess title animation */
-
- #include "advlaser.h"
- #include "advsound.h"
-
- /* External variables */
- extern struct Screen *screen; /* From ADVGRAPH.C */
- extern struct BitMap primary_bitmap; /* From ADVGRAPH.C */
- extern struct BitMap backup_bitmap;
- extern struct BitMap *current_bitmap;
- extern int bitmap_to_use; /* From ADVGRAPH.C */
- extern struct TextAttr font;
-
- /* Local variables */
- int xd[TITLEPOINTS], yd[TITLEPOINTS]; /* X and Y directions for all letter points */
- int xv[TITLEPOINTS], yv[TITLEPOINTS]; /* X and Y velocities for all letter points */
- int xp[TITLEPOINTS], yp[TITLEPOINTS]; /* X and Y positions for all letter points */
- short lax[] = {2, 0, 2, 4, 1, 3, -1}; /* Letter A's X & Y point definitions */
- short lay[] = {0, 6, 0, 6, 3, 3}; /* (defined as 5 X 7) */
- short lcx[] = {0, 4, 0, 0, 0, 4, -1}; /* Letter C's definition */
- short lcy[] = {0, 0, 0, 6, 6, 6};
- short ldx[] = {0, 3, 4, 4, 0, 3, 0, 0, 3, 4, 3, 4, -1}; /* D */
- short ldy[] = {0, 0, 1, 5, 6, 6, 0, 6, 0, 1, 6, 5};
- short lex[] = {0, 4, 0, 0, 0, 4, 0, 3, -1}; /* E */
- short ley[] = {0, 0, 0, 6, 6, 6, 3, 3};
- short lhx[] = {0, 0, 4, 4, 0, 4, -1}; /* H */
- short lhy[] = {0, 6, 0, 6, 3, 3};
- short llx[] = {0, 0, 0, 4, -1}; /* L */
- short lly[] = {0, 6, 6, 6};
- short lnx[] = {0, 0, 4, 4, 0, 4, -1}; /* N */
- short lny[] = {0, 6, 0, 6, 0, 6};
- short lrx[] = {0, 4, 4, 4, 4, 1, 1, 4, 0, 0, -1}; /* R */
- short lry[] = {0, 0, 0, 3, 3, 3, 3, 6, 0, 6};
- short lsx[] = {0, 4, 0, 0, 0, 4, 4, 4, 0, 4, -1}; /* S */
- short lsy[] = {0, 0, 0, 3, 3, 3, 3, 6, 6, 6};
- short lvx[] = {0, 2, 2, 4, -1}; /* V */
- short lvy[] = {0, 6, 6, 0};
- int xdestpt[] = {15, 54, 93, 132, 171, 210, 249, 288, /* Upper left x positions */
- 73, 112, 151, 190, 229, /* of letter "cells" */
- 73, 112, 151, 190, 229}; /* (destinations) */
- int ydestpt[] = {22, 22, 22, 22, 22, 22, 22, 22, /* ADVANCED */
- 74, 74, 74, 74, 74, /* LASER */
- 126, 126, 126, 126, 126}; /* CHESS */
- int addli, addlk;
-
-
-
- title()
- {
- register int i;
-
- reset_view();
- clear_screen(&primary_bitmap);
- /* Fade all colors FROM the background color, don't modify sound */
- fade_all(FALSE, FALSE);
- title_reset(); /* Reset the title variables and points */
- init_points(); /* Initialize the title letter points */
- set_title_drawing(); /* Initialize drawing parameters for title */
- dequeue_window();
- title_sound(TRUE);
- wait_for_release( !move_points(TRUE) );
- for(i=0; i<TITLEPOINTS; i++)
- {
- xd[i] = SCREENX / 2;
- yd[i] = SCREENY / 2;
- }
- move_points(FALSE);
- title_sound(FALSE);
- clear_screen(&primary_bitmap);
- reset_view();
- /* Fade all colors to background, don't modify sound */
- fade_all(TRUE, FALSE);
- ShowTitle(screen, (long)TRUE); /* Display screen's title bar */
- }
-
-
-
- title_reset()
- {
- addli = addlk = 0;
- }
-
-
-
- init_points() /* Figures out destination coordinates of all letter points */
- {
- register int i;
-
- addl(lax, lay); /* Add letter A to the xd & yd arrays */
- addl(ldx, ldy); /* Add letter D, etc... */
- addl(lvx, lvy);
- addl(lax, lay);
- addl(lnx, lny);
- addl(lcx, lcy);
- addl(lex, ley);
- addl(ldx, ldy);
- addl(llx, lly);
- addl(lax, lay);
- addl(lsx, lsy);
- addl(lex, ley);
- addl(lrx, lry);
- addl(lcx, lcy);
- addl(lhx, lhy);
- addl(lex, ley);
- addl(lsx, lsy);
- addl(lsx, lsy);
- for(i=0; i<TITLEPOINTS; i++)
- {
- xv[i] = yv[i] = 0;
- xp[i] = SCREENX / 2;
- yp[i] = SCREENY / 2;
- }
- }
-
-
-
- set_title_drawing() /* Initialize title drawing parameters */
- {
- SetAPen(&screen->RastPort, (long)TITLEPENCOLOR); /* Set line colors */
- SetDrMd(&screen->RastPort, JAM1); /* Set drawing mode */
- SetDrPt(&screen->RastPort, (long)0xFFFF); /* Solid lines */
- }
-
-
-
- wait_for_release(done)
- register int done;
- {
- register struct RastPort *rp;
- register BOOL first = TRUE;
- static struct IntuiText itext =
- {
- (int)TITLEPENCOLOR, 1, /* FrontPen, BackPen */
- JAM1, /* Drawing mode */
- 0, 0, /* LeftEdge, TopEdge */
- &font, /* ITextFont */
- (UBYTE *)NULL, /* Text (filled in below) */
- NULL /* NextText */
- };
-
-
- if(!done) return;
-
- rp = &screen->RastPort;
- itext.IText = (UBYTE *)"by Mike M. Duppong";
- PrintIText(&screen->RastPort, &itext, 90L, 170L);
- itext.IText = (UBYTE *)"(c) 1989 COMPUTE! Publications, Inc.";
- PrintIText(&screen->RastPort, &itext, 21L, 180L);
- while(!release())
- {
- rnd_title_chord(first);
- first = FALSE;
- }
- SetAPen(rp, TITLEPENCOLOR);
- }
-
-
-
- move_points(beginning) /* Moves all points in the xd & yd arrays */
- register int beginning;
- {
- register int i, d, cont;
-
- do
- {
- flip_screens();
- clear_screen(current_bitmap);
- cont = FALSE;
- for(i=0; i<TITLEPOINTS; i++)
- {
- if(xp[i] != xd[i] || yp[i] != yd[i])
- {
- cont = TRUE;
- d = xv[i] + SIGN(xd[i] - xp[i]);
- if(abs(d) < VELLIMIT) xv[i] = d;
- d = yv[i] + SIGN(yd[i] - yp[i]);
- if(abs(d) < VELLIMIT) yv[i] = d;
- xp[i] += xv[i];
- yp[i] += yv[i];
- if(abs(xp[i] - xd[i]) < DIST && abs(yp[i] - yd[i]) < DIST)
- {
- xp[i] += SIGN(xd[i] - xp[i]);
- yp[i] += SIGN(yd[i] - yp[i]);
- }
- }
- }
- if(beginning && cont == TRUE) modify_title_sound(1);
- else if(!beginning && cont == TRUE) modify_title_sound(-1);
- draw_points();
- new_view();
- }while(!release() && cont);
- return(cont); /* This value tells whether the letters were still moving or not */
- }
-
-
-
- draw_points()
- {
- int i;
-
- for(i=0; i<TITLEPOINTS; i+=2)
- {
- Move(&screen->RastPort, (long)xp[i], (long)yp[i]);
- Draw(&screen->RastPort, (long)xp[i + 1], (long)yp[i + 1]);
- }
- }
-
-
-
- addl(xsrc, ysrc) /* Adds a letter to the X & Y destination arrays */
- short *xsrc, *ysrc;
- {
- int j = 0;
-
- while(xsrc[j] != -1)
- {
- xd[addli] = xsrc[j] * 4 + xdestpt[addlk];
- yd[addli] = ysrc[j] * 5 + ydestpt[addlk];
- ++addli; /* Destination point counter */
- ++j; /* Source point counter */
- }
- ++addlk; /* Letter counter */
- }
-
-